{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#导入必要的工具包\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "from sklearn import metrics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "#读取聚类数据\n",
    "import scipy.io as sio\n",
    "eventContMatrix = sio.mmread(\"EV_eventContMatrix\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "#CH_scores计算函数\n",
    "from sklearn.cluster import MiniBatchKMeans\n",
    "\n",
    "def K_cluster_analysis(K,df):\n",
    "    #print(\"K-means begin with clusters:{}\".format(K)):\n",
    "        km = MiniBatchKMeans(n_clusters = K)\n",
    "        km.fit(df)\n",
    "        \n",
    "        cluster_result = km.predict(df)\n",
    "        CH_score = metrics.silhouette_score(df,cluster_result)\n",
    "        #print(\"CH_score:{}\".format(CH_score))\n",
    "        \n",
    "        return CH_score\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "#CH_scores计算\n",
    "CH_scores = []\n",
    "Ks = [10,20,30,40,50,60,70,80,90,100]\n",
    "for K in Ks:\n",
    "    ch = K_cluster_analysis(K,eventContMatrix)\n",
    "    CH_scores.append(ch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.14306650691793463, 0.16001148524374245, 0.14749948547982278, 0.12915402818058302, 0.1275220057177097, 0.1262662326158374, 0.1280781600924606, 0.09213068260224215, 0.14259237239486608, 0.13617397619913835]\n"
     ]
    }
   ],
   "source": [
    "#打印CH_scores\n",
    "print (CH_scores)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7f993a958f28>]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJzt3XuYU+W5/vHvwyAiKHIaUU6CghytoAOiVWqlKrIVcIK7YlvFraW2Yru1arXbVsVNPbTW1ta6xZbuan/WIypVt1i1Bw2KDKgoIjICwoDoKOKZw8Dz++MNFzNDhlkzk2RlJvfnunKFJCsrz8R4Z+Vdaz2vuTsiIlIYWsVdgIiI5I5CX0SkgCj0RUQKiEJfRKSAKPRFRAqIQl9EpIAo9EVECohCX0SkgCj0RUQKSOu4C6ita9eu3qdPn7jLEBFpVhYuXPi+uxfXt1zehX6fPn0oKyuLuwwRkWbFzN6OspyGd0RECohCX0SkgCj0RUQKiEJfRKSAKPRFRApIpNA3s7FmtszMys3s8jSPjzazRWZWZWaTaj3W28yeNLOlZva6mfXJTOkiItJQ9Ya+mRUBtwInA4OByWY2uNZiq4EpwN1pVnEn8HN3HwSMBN5rSsEiItJ4Ubb0RwLl7r7C3bcA9wATqi/g7qvcfTGwvfr9qS+H1u7+t9Ryn7r755kpPT999hn8/vfhWkQk30QJ/R7Ammq3K1L3RXEIsNHMZpvZS2b289QvhxrMbKqZlZlZWWVlZcRV56eLLoJvfxtKS2Hz5rirERGpKUroW5r7os6m3ho4FrgEGAEcRBgGqrky95nuXuLuJcXF9Z5FnLcefxzuuANGj4Ynn4RvfQu2bYu7KhGRnaKEfgXQq9rtnsC6iOuvAF5KDQ1VAQ8DhzesxObhgw/g3HNh6NAQ+DfdBPffD9/9LnjUr0gRkSyL0ntnAdDfzPoCa4EzgDMjrn8B0MnMit29Ej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ez7sp7v7hliKjIGZHQdc4u6nmNlBhC3/zsBLwDfdfXOc9eWKmQ0Dfg+0AVYA5xA2tgrys2Fm1wBfJxz19hJwHmGcuiA+H2b2F+A4QjfNd4GrgIdJ83lIfTH+lnC0z+fAOe5e1uQaFPoiIoVDwzsiIgVEoS8iUkAU+iIiBUShLyJSQBT6IiIFRKEvIlJAFPoiIgVEoS8iUkD+P08q16f4enh0AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#CH_scores图形展示\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "\n",
    "plt.plot(Ks, np.array(CH_scores), 'b-')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 结果分析\n",
    "\n",
    "CH_scores在20处取得最优值"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
